<style>
.layui-icon-close{color:red;font-weight: bold;}
.layui-icon-ok{color:#5FB878;font-weight: bold;}
</style>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>CMS - 字段列表</em>
                    ...
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">
								
								<div class="fixed-table-toolbar">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
											</a>
											{if condition="$adminController->vif('field','add')"}
											<a href="{:url('add', ['pid'=>$pid])}" class="btn btn-success btn-add" title="添加"><i class="fa fa-plus"></i> 添加</a>
											{/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
										<div class="keep-open btn-group" title="列">
											<button type="button" aria-label="columns" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
												<i class="glyphicon glyphicon-th icon-th"></i>
												<span class="caret"></span>
											</button>
												<ul class="dropdown-menu" id="table_menu">
												
											</ul>
										</div>
									</div>
								</div>
								<div class="fixed-table-container" style="padding-bottom: 0px;">
									<div class="fixed-table-body">
										<table id="table" class="table table-striped table-bordered table-hover" width="100%">
											<thead>
												<tr>
													<th data-status="1" width="120"><div class="th-inner">字段类型</div></th>
													<th data-status="1" width="120"><div class="th-inner">字段名称</div></th>
													<th data-status="1" width="80"><div class="th-inner">字段别名</div></th>
													<th data-status="1" width="120"><div class="th-inner">默认值</div></th>
													<th data-status="1" width="80"><div class="th-inner">最小长度</div></th>
													<th data-status="1" width="150"><div class="th-inner">最大长度</div></th>
													<th data-status="1" width="80"><div class="th-inner">必填</div></th>
													<th data-status="1" width="80"><div class="th-inner">唯一</div></th>
													<th data-status="1" width="80"><div class="th-inner">附表字段</div></th>
													<th data-status="1" width="80"><div class="th-inner">状态</div></th>
													<th data-status="1" width="170"><div class="th-inner">创建者</div></th>
													<th data-status="1" width="170"><div class="th-inner">添加时间</div></th>
													<th data-status="1" width="170"><div class="th-inner" style="text-align: right;">操作</div></th>
												</tr>
											</thead>
											
											<tbody id="content-main">
													{php}$i=count($list)-1;{/php}
													{foreach name="list" item="v"}
													<tr class="del-{$v.if_id}">
														<td align="center">
															{switch name="v.if_type"}
																{case value="text"}单行文本{/case}
																{case value="textarea"}多行文本{/case}
																{case value="int"}数字{/case}
																{case value="editor"}编辑器{/case}
																{case value="enclosure"}附件{/case}
																{case value="image"}单图片{/case}
																{case value="images"}多图片{/case}
																{case value="radio"}单选{/case}
																{case value="checkbox"}多选{/case}
																{case value="select"}列表{/case}
															{/switch}
														</td>
														<td align="center">{$v.if_name}</td>
														<td align="center">{$v.if_title}</td>
														<td align="center">{$v.if_default}</td>
														<td align="center">{$v.if_min}</td>
														<td align="center">{$v.if_max}</td>
														<td align="center">
															{if condition="$v.if_notnull == 1"}
																<i class="layui-icon layui-icon-ok">&#xe605;</i>
															{else /}
															<i class="layui-icon layui-icon-close">&#x1006;</i> 
															{/if}
														</td>
														<td align="center">
															{if condition="$v.if_only == 1"}
																<i class="layui-icon layui-icon-ok">&#xe605;</i>
															{else /}
															<i class="layui-icon layui-icon-close">&#x1006;</i>
															{/if}
														</td>
														<td align="center">
															{if condition="$v.if_is_data == 1"}
																<i class="layui-icon layui-icon-ok">&#xe605;</i>
															{else /}
																<i class="layui-icon layui-icon-close">&#x1006;</i>
															{/if}
														</td>
														<td align="center">
															{if condition="$v.if_status == 1"}
																<a href="javascript:status('{:url('status', ['pid'=>$v['if_id'], 'status'=>0])}');">
																	<i class="layui-icon layui-icon-ok">&#xe605;</i>
																</a>
															{else /}
																<a href="javascript:status('{:url('status', ['pid'=>$v['if_id'], 'status'=>1])}');">
																	<i class="layui-icon layui-icon-close">&#x1006;</i>
																</a>
															{/if}
														</td>
														<td align="center">{$v.if_author}</td>
														<td align="center">{$v.if_add_time|date="Y-m-d H:i:s",###}</td>
														<td style="text-align: right; vertical-align: middle; ">
															{if condition="$adminController->vif('field','sort') && $key!=0"}
															<a href="javascript:status('{:url('sort', ['pid'=>$v['if_id'], 'type'=>1])}');" class="btn btn-xs btn-success btn-editone" title="排序">
																<i class="layui-icon layui-icon-up" style="font-size: 12px;">&#xe619;</i>
															</a>
															{/if}
															{if condition="$adminController->vif('field','sort') && $i != $key"}
															<a href="javascript:status('{:url('sort', ['pid'=>$v['if_id'], 'type'=>2])}');" class="btn btn-xs btn-danger btn-delone del_menu" title="排序">
																<i class="layui-icon layui-icon-down" style="font-size: 12px;">&#xe61a;</i>
															</a>
															{/if}
															
															
															{if condition="$adminController->vif('field','upd')"}
															<a href="{:url('field/upd', ['pid'=>$v['if_id']])}" class="btn btn-xs btn-success btn-editone" title="编辑">
																<i class="fa fa-pencil"></i>
															</a>
															{/if}
															{if condition="$adminController->vif('field','delete')"}
															<button data-id="{$v.if_id}" onclick="return del(this)" class="btn btn-xs btn-danger btn-delone del_menu" title="删除">
																<i class="fa fa-trash"></i>
															</button>
															{/if}
														</td>
													</tr>
													{/foreach}
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<script>

layui.use(['form'], function(){
  var form = layui.form;
});
// 删除
function del(_this) {
	var id = $(_this).attr('data-id');
	$.ajax({
		type: 'post',
		data: {'id':id},
		url: '{:url("delete")}',
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
}
// 切换状态
function status(href) {
	$.ajax({
		type: 'post',
		data: {},
		url: href,
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
}

</script>
